//产品第二层

//引用第三层数据
const {getInsures,addInsures,delInsures,getInsuresById,updateInsures} = require('../dao/insuresDao')

//获取保险产品数据
module.exports.getInsures = async a =>{
    const data = await getInsures(a)
    return {
        status:1,
        message:'获取保险产品数据成功',
        data
    }
}

//新增保险产品
module.exports.addInsures = async a =>{
    const data = await addInsures(a)
    if(data._id){
        return{
            status:1,
            message:'新增保险产品成功'
        }
    }else{
        return{
            status:0,
            message:'新增保险产品失败'
        }
    }
}

//删除保险产品  a为_id b为delete:true
module.exports.delInsures = async (a,b) =>{
    const data = await delInsures(a,b)
    if(data.nModified > 0){
        return{
            status:1,
            message:'删除保险产品成功'
        }
    }else{
        return{
            status:0,
            message:'删除保险产品失败'
        }
    }
}

//获取修改产品数据
module.exports.getInsuresById = async a =>{
    const data = await getInsuresById(a)
    return{
        status:1,
        message:'获取修改产品数据成功',
        data
    }
}

//修改产品数据
module.exports.updateInsures = async a=>{
    const data = await updateInsures(a)
    if(data.nModified>0){
        return{
            status:1,
            message:'修改产品数据成功',
            data
        }
    }else{
        return{
            status:0,
            message:'修改产品数据失败',
            data
        }
    }
}